import React, { useEffect, useState } from 'react'
import { useHistory, useParams } from 'umi'
import { NavBar } from 'antd-mobile'
export default function Detail(props: any) {

  const param: any = useParams();
  const [detail, setdetail] = useState(
    {
      synopsis: ""
    }
  );

  useEffect(() => {
    const { id } = param;

    fetch(`https://m.maizuo.com/gateway?filmId=${id}&k=7852739`, {
      headers: {
        'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.1","e":"16722220591298527527370753"}',
        'X-Host': 'mall.film-ticket.film.info'
      }
    }).then(res => res.json()).then(res => {
      console.log(res.data.film.synopsis);
      return setdetail({
        synopsis: res.data.film.synopsis
      });
    });
    return () => {
      console.log("sy", detail.synopsis);
    }
  }, []);

  const history = useHistory()
  function back() {
    console.log("点击的返回按钮");
    console.log("属性", props);
    history.goBack();
  }

  return (
    <div>
      <NavBar onBack={back}>电影详情</NavBar>
      <div>
        {detail.synopsis}
      </div>
    </div>

  )
}
